<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta name="generator" content="PHPDoctor 2RC4 (http://peej.github.com/phpdoctor/)">
<meta name="when" content="Mon, 02 May 2011 02:46:56 +0000">

<link rel="stylesheet" type="text/css" href="../stylesheet.css">
<link rel="start" href="../overview-summary.html">

<title>session.php (Cornice)</title>

</head>
<body id="file" onload="parent.document.title=document.title;">

<div class="header">
<h1>Cornice</h1>
<ul>
<li><a href="../overview-summary.html">Overview</a></li>
<li>Package</li><li>Class</li><li>Tree</li><li><a href="../overview-files.html">Files</a></li>
<li><a href="../deprecated-list.html">Deprecated</a></li>
<li><a href="../todo-list.html">Todo</a></li>
<li><a href="../index-all.html">Index</a></li>
</ul>
</div>

<div class="small_links">
<a href="../index.html" target="_top">Frames</a>
<a href="../source\session.php.html" target="_top">No frames</a>
</div>
<hr>

<h1>session.php</h1>
<div class="comment" id="overview_description"><p>============================================================================
Cornice PHP Framework & Website Builder
Freeware (f) 2011 by Inforo Software & Computer
============================================================================</p></div>

<hr>

<a name="line1"></a><pre><?php
<a name="line2"></a>/**
<a name="line3"></a> *============================================================================
<a name="line4"></a> * Cornice PHP Framework & Website Builder
<a name="line5"></a> * Freeware (f) 2011 by Inforo Software & Computer
<a name="line6"></a> *============================================================================
<a name="line7"></a> */
<a name="line8"></a> 
<a name="line9"></a>/**
<a name="line10"></a> * Class used for managing session data
<a name="line11"></a> * @author Nicola Dinh
<a name="line12"></a> * @version 2011.04.2702
<a name="line13"></a> */
<a name="line14"></a>class session {
<a name="line15"></a>
<a name="line16"></a>  /**
<a name="line17"></a>   * Default instance level constructor
<a name="line18"></a>   * Just decorative, should not be called due to having only static methods
<a name="line19"></a>   */
<a name="line20"></a>  public function __construct() {
<a name="line21"></a>    //
<a name="line22"></a>  }
<a name="line23"></a>  
<a name="line24"></a>  /**
<a name="line25"></a>   * Initialise the session (used for both starting or resuming)
<a name="line26"></a>   */
<a name="line27"></a>  public static function initialise() {
<a name="line28"></a>    $lf_on_server = config::get_config_value("session/lifetime/server");
<a name="line29"></a>    $lf_of_cookie = config::get_config_value("session/lifetime/cookie");
<a name="line30"></a>    $module_name  = request::get_module_name();
<a name="line31"></a>  
<a name="line32"></a>    //set ini
<a name="line33"></a>    ini_set("session.gc_maxlifetime", $lf_on_server);  
<a name="line34"></a>    ini_set("session.cookie_lifetime",$lf_of_cookie);
<a name="line35"></a>    session_name($module_name."_sid");
<a name="line36"></a>    session_start();    
<a name="line37"></a>
<a name="line38"></a>    //update session cookie lifetime 
<a name="line39"></a>    if (strlen(session_id())>0)
<a name="line40"></a>      setcookie(session_name(),session_id(),time()+$lf_of_cookie,"/");
<a name="line41"></a>  }
<a name="line42"></a>  
<a name="line43"></a>  /**
<a name="line44"></a>   * Destroy session of current visitor
<a name="line45"></a>   */
<a name="line46"></a>  public static function destroy() {
<a name="line47"></a>    session_destroy();
<a name="line48"></a>  }
<a name="line49"></a>   
<a name="line50"></a>  /**
<a name="line51"></a>   * Get value of a certain session variable
<a name="line52"></a>   * @param string $var_name The name of session variable
<a name="line53"></a>   * @return mixed The session variable
<a name="line54"></a>   */
<a name="line55"></a>  public static function get_value($var_name) {
<a name="line56"></a>    return isset($_SESSION[$var_name])? $_SESSION[$var_name]:null;
<a name="line57"></a>  }
<a name="line58"></a>  
<a name="line59"></a>  /**
<a name="line60"></a>   * Clear a session variable
<a name="line61"></a>   * @param string $var_name The name of session variable
<a name="line62"></a>   */
<a name="line63"></a>  public static function clear_value($var_name) {
<a name="line64"></a>    if (isset($_SESSION[$var_name]))
<a name="line65"></a>      unset($_SESSION[$var_name]);
<a name="line66"></a>  }
<a name="line67"></a>  
<a name="line68"></a>  /**
<a name="line69"></a>   * Set a session variable
<a name="line70"></a>   * @param string $var_name The name of session variable
<a name="line71"></a>   * @param mixed $var_value The value of session variable to set
<a name="line72"></a>   */
<a name="line73"></a>  public static function set_value($var_name,$var_value) {
<a name="line74"></a>    $_SESSION[$var_name] = $var_value;
<a name="line75"></a>  }
<a name="line76"></a>}</pre>
<div class="header">
<h1>Cornice</h1>
<ul>
<li><a href="../overview-summary.html">Overview</a></li>
<li>Package</li><li>Class</li><li>Tree</li><li><a href="../overview-files.html">Files</a></li>
<li><a href="../deprecated-list.html">Deprecated</a></li>
<li><a href="../todo-list.html">Todo</a></li>
<li><a href="../index-all.html">Index</a></li>
</ul>
</div>

<div class="small_links">
<a href="../index.html" target="_top">Frames</a>
<a href="../source\session.php.html" target="_top">No frames</a>
</div>
<hr>

<p id="footer">This document was generated by <a href="http://peej.github.com/phpdoctor/">PHPDoctor: The PHP Documentation Creator</a></p>

</body>

</html>